#!/usr/bin/env bash
set -ex

# TODO has not network but replays fine
# -device rtl8139,netdev=net1 \

# Has network, but replay hangs.
#-device virtio-net-device,netdev=net1 \

cmd="\
time \
./buildroot/output.aarch64~/host/usr/bin/qemu-system-aarch64 \
-M virt \
-cpu cortex-a57 \
-append 'root=/dev/sda nokaslr norandmaps printk.devkmsg=on printk.time=y - lkmc_eval=\"/rand_check.out;wget -S google.com;/poweroff.out;\"' \
-kernel ./buildroot/output.aarch64~/images/Image \
-nographic \
\
-device virtio-net-device,netdev=net1 \
-netdev user,id=net1 \
-object filter-replay,id=replay,netdev=net1 \
"
echo "$cmd"
eval "$cmd -icount 'shift=7,rr=record,rrfile=replay.bin'"
eval "$cmd -icount 'shift=7,rr=replay,rrfile=replay.bin'"
